﻿
using System;
using System.Web;
using System.Web.UI.HtmlControls;
using AnyOffice.BIZ;
using AnyOffice.Components;
namespace AnyOffice.module.oc
{
    public partial class index : BasePage
    {
        public string action;
        public string attachmentid;
        public string filename;
        public bool isexcel;
        public bool isppt;
        public bool isword;      
        public string op;
        public string url;
        public string username;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.attachmentid = (Request.QueryString["attachment_id"] == null) ? "" : Request.QueryString["attachment_id"].ToString();
                this.filename = (Request.QueryString["name"] == null) ? "" : Request.QueryString["name"].ToString();
                if (!AttachmentBiz.Contains(this.attachmentid))
                {
                    Response.Write(base.ShowErrorNoNav("无访问权限"));
                    Response.End();
                }
                else
                {
                    if (this.filename.ToLower().EndsWith(".doc") || this.filename.ToLower().EndsWith(".docx"))
                    {
                        this.isword = true;
                    }
                    else
                    {
                        this.isword = false;
                    }
                    if (this.filename.ToLower().EndsWith(".xls") || this.filename.ToLower().EndsWith(".xlsx"))
                    {
                        this.isexcel = true;
                    }
                    else
                    {
                        this.isexcel = false;
                    }
                    if (this.filename.ToLower().EndsWith(".ppt") || this.filename.ToLower().EndsWith(".pptx"))
                    {
                        this.isppt = true;
                    }
                    else
                    {
                        this.isppt = false;
                    }
                    this.op = (Request.QueryString["op"] == null) ? "0" : Request.QueryString["op"].ToString();
                    if (this.op == "1")
                    {
                        this.litTitle.InnerText = "Office 文档在线编辑";
                    }
                    else
                    {
                        this.litTitle.InnerText = "Office 文档在线阅读";
                    }
                    UserCache cache = new UserCache();
                    this.username = cache.UserName;
                    this.url = "readdisk.aspx?attachment_id=" + this.attachmentid + "&name=" + Server.UrlEncode(this.filename);
                }
            }
        } 

 

    }
}
